package leetcode;

import java.util.Stack;

/**
 * Write a function that takes a string as input and returns the string reversed.
 * Example:
 * Given s = "hello", return "olleh".
 */
public class ReverseString {
    public static void main(String[] args) {
        System.out.println(reverseString("a plan"));
    }
    public static String reverseString(String s) {
        char[] chars = s.toCharArray();
        int start = 0,end = chars.length - 1;
        char temp;
        while (start < end){
            temp = chars[start];
            chars[start] = chars[end];
            chars[end] = temp;
            start++;
            end--;
        }
        return new String(chars);
    }
}
